import moment from 'moment';
import { Toast } from 'antd-mobile';
import { routerRedux } from 'dva/router';
import { wxPay, unionPay } from '../services/weixin';
import { source, update } from  '../services/component';
import { particulars,deletee } from '../services/supportparticular';


const empty = require('is-empty');
export default {
  namespace:'particulars',
  state:{},

  subscriptions:{
    setup({dispatch, history}) {
      history.listen(({pathname, query}) => {
        if(pathname.toString() == "/work/dysupportxx/support"){;
        }
      });
    }
  },
  effects: {
    *particular({ payload }, { call,put,select }) {
      if (payload){
        const data = yield call(particulars, {id:payload,relation:["org"] });
        yield put({
          type: 'success',
          payload: {
            org:data.data.ret.org.short_name,
            type1:data.data.ret.content,
            name1:data.data.ret.object,
            id1:data.data.ret.id
          },
        })
        // payload.resolve(data)
      }
      },
    *particulardelete({ payload }, { call,put,select }) {
        const dataa = yield call(deletee, payload);
        console.log(dataa,"data");
      console.log(dataa.data.code,"data");
      if (dataa.data.code==200){
        Toast.success('取消成功！', 1);
        yield put(
          routerRedux.push({
          pathname: "/work/dysupportxx",
        })
      )

      }
    }

  },

  reducers: {
    success(state, action) {
      return {...state, ...action.payload};
    }
  }
}
